#include "mysig.h"

void (*signal(int, void (*) (int))) (int);
static void child_handler(int);

int main() {
    int res;
    // signal(SIGCHLD, SIG_IGN); /* This will forbid generating zombie child proc */
    signal(SIGCHLD, child_handler); /* This will forbid generating zombie child proc */
    if ((res = fork()) < 0) {
        printf("error in fork\n");
        exit(EXIT_FAILURE);
    }
    if (res == 0) {
        _exit(EXIT_SUCCESS);
    }
    if (res > 0) {
        sleep(60);
    }
    return EXIT_SUCCESS;
}

static void child_handler(int sig) {
    printf("receive signal %d\n", sig);
}
